# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Arch Haskell Team <arch-haskell@haskell.org>

pkgname=hlint
pkgver=3.3.6
pkgrel=131
pkgdesc="Source code suggestions"
url="http://community.haskell.org/~ndm/hlint/"
license=("BSD")
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-aeson' 'haskell-ansi-terminal' 'haskell-cmdargs' 'haskell-cpphs'
         'haskell-data-default' 'haskell-extra' 'haskell-file-embed' 'haskell-filepattern'
         'haskell-ghc' 'haskell-ghc-lib-parser-ex' 'haskell-hscolour' 'haskell-refact'
         'haskell-syb' 'haskell-uniplate' 'haskell-unordered-containers' 'haskell-utf8-string'
         'haskell-vector' 'haskell-yaml')
conflicts=('haskell-hlint')
replaces=('haskell-hlint')
makedepends=('ghc')
source=("https://hackage.haskell.org/packages/archive/${pkgname}/${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha512sums=('efc42480ca1382741f65b8f1d84b5c7fe1bd0d94e39163c0e7488862300d19f45d4e55fb501b94a45b089508f44bf196beb3437ae9eee8fc765c588c8eff7916')

build() {
    cd "${srcdir}/${pkgname}-${pkgver}"
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm \
            -fgpl -fthreaded
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd "${srcdir}/${pkgname}-${pkgver}"
    install -D -m744 register.sh   "${pkgdir}/usr/share/haskell/register/${pkgname}.sh"
    install -D -m744 unregister.sh "${pkgdir}/usr/share/haskell/unregister/${pkgname}.sh"
    runhaskell Setup copy --destdir="${pkgdir}"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "${pkgdir}/usr/share/doc/${pkgname}/COPYING.BSD3"
}
